<template>
  <div>
    <MyContainer style="margin-top: 20px;">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/fm/index' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>详情</el-breadcrumb-item>
      </el-breadcrumb>
      <el-card>
        <el-row :gutter="12">
          <el-col :span="15">
            <img :src="info.cover" style="width: 100%;"/>
          </el-col>
          <el-col :span="9">
            <h2>{{info.name}}</h2>
            <div class="pros-other">
              <p>价格 : ￥ <b style="color:orange;font-size: 20px;">{{ info.price }}</b>元</p>
              <p>简介 ： <span>{{info.intro}}</span></p>
              <p>提示 ： <span>支付支持蚂蚁花呗，信用卡支付，集分宝等，注意您的资金安全！！</span></p>
            </div>

            <div class="mb20">
              <el-divider content-position="left">数量</el-divider>
              <el-input-number v-model="num" :min="1" :max="10"></el-input-number>
            </div>
            <el-button type="primary" @click="bay" icon="el-icon-star-off">添加购物车</el-button>

          </el-col>
        </el-row>
      </el-card>

      <el-divider content-position="left">详细介绍</el-divider>
      <div class="notice" v-html="info.detail">
      </div>
    </MyContainer>
    <Footer/>
  </div>
</template>

<script>
import MyContainer from '@/components/Me/MyContainer'
import {mapGetters} from 'vuex'
import Footer from "@/views/fm/components/Footer";
import {getProduct} from "@/api/system/product";
import {addCart} from "@/api/system/cart";

export default {
  name: 'Detail',
  components: {Footer, MyContainer},
  computed: {
    ...mapGetters([
      'userId',
      'avatar',
      'name'
    ]),
  },
  data() {
    return {
      info: {},
      id: this.$route.params.id,
      num: 1,
    }
  },
  methods: {
    bay() {
      addCart({
        userId: this.userId,
        productId: this.id,
        num: this.num,
      }).then(res => {
        this.$modal.msgSuccess('添加成功');
      })
    },
    getInfo() {
      getProduct(this.id).then(res => {
        this.info = res.data
      })
    },
  },
  created() {
    this.getInfo()
  }
}
</script>

<style scoped lang="scss">

img {
  width: 100%;
  max-height: 350px;
}

.hot {
  font-size: 14px;
  color: #ff4848;
}

.pros-other {
  background: #eee;
  font-size: 14px;
  padding: 10px 0 10px 10px;
  margin: 10px 0;
}

.notice {
  border: solid 1px #ddd;
  padding: 35px 48px;
}
</style>
